﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BalanceSheet.aspx.cs" Inherits="Main_Reports_Accounts_BalanceSheet" Culture="en-GB" %>


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Profit & Loss A/c</title>
    <link href="../../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .LeftAlign
        {
            padding-left: 7px;
        }
        .RightAlign
        {
            padding-right: 5px;
        }
    </style>

    <script type="text/javascript">
        function Validation() {
            var flag = true;
            var txtFromdate = document.getElementById("txtFromDate").id;
            var txtTodate = document.getElementById("txtToDate").id;
            if (document.getElementById("txtFromDate").value == '') {
                alert('Specify From date');
                flag = false;
            }
            else if (document.getElementById("txtToDate").value == '') {
                alert('Specify To date');
                flag = false;
            }
            else {
                if (isDate(txtFromdate) && isDate(txtTodate)) {
                    var dateArray = new Array();
                    dateArray = document.getElementById("txtFromDate").value.split("/");
                    var day1 = dateArray[0];
                    var month1 = dateArray[1];
                    var year1 = dateArray[2];
                    dateArray = document.getElementById("txtToDate").value.split("/");
                    var day2 = dateArray[0];
                    var month2 = dateArray[2];
                    var year2 = dateArray[2];

                    if (day1.length < 2) {
                        day1 = '0' + day1;
                    }
                    if (month1.length < 2) {
                        month1 = '0' + month1;
                    }
                    if (day2.length < 2) {
                        day2 = '0' + day2;
                    }
                    if (month2.length < 2) {
                        month2 = '0' + month2;
                    }
                    var date1 = new Date(year1, month1 - 1, day1);
                    var date2 = new Date(year2, month2 - 1, day2);
                    if (date1 > date2) {
                        alert('Date Could Not be less than From Date');
                        document.getElementById(txtFromdate).focus();
                        flag = false;

                    }
                }
                else {
                    flag = false;
                }
            }
            return flag;
        }
        function isDate(txtDateId) {
            // date length should be 10 characters - no more, no less            
            var Ctrl = document.getElementById(txtDateId);
            var txtDate = Ctrl.value;
            var flag = true;

            // extract day, month and year from the txtDate string
            // expected format is dd/mm/yyyy
            var day = '';
            var month = '';
            var year = '';
            var dateArray = new Array();
            var count = 0;
            for (var j = 0; j < txtDate.length; j++) {
                var chara = txtDate.charAt(j);
                if (chara == '/') {
                    count += 1;
                }
            }
            if (count != 2) {
                alert('Invalid date !');
                return false;
            }
            dateArray = txtDate.split("/");


            day = dateArray[0];
            month = dateArray[1];
            year = dateArray[2];


            if (year.length != 4) {
                alert('Invalid date !');
                return false;
            }
            var finYear = document.getElementById("hidFinyear").value;
            if (month >= 4 && year != parseInt(finYear)) {
                alert('Date Should be between 01/04/' + finYear + ' and 31/03/' + (parseInt(finYear) + 1));
                return false;
            }
            else if (month < 4 && year != (parseInt(finYear) + 1)) {
                alert('Date Should be between 01/04/' + finYear + ' and 31/03/' + (parseInt(finYear) + 1));
                return false;
            }



            if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
                if (day > 31) {
                    alert('Date Should not be Greater than 31');
                    Ctrl.focus();
                    flag = false;
                }
            }
            //for have only 30 day
            else if (month == 4 || month == 6 || month == 9 || month == 11) {
                if (day > 30) {
                    alert('Date Should not be Greater than 30');
                    Ctrl.focus();
                    flag = false;
                }
            }
            //for Febuary 
            else if (month == 2) {
                var leap = year % 4;
                if (leap == 0) {
                    if (day > 29) {
                        alert('february have only 29 days');
                        Ctrl.focus();
                        flag = false;
                    }
                }
                else {
                    if (day > 28) {
                        alert('february have only 28 days');
                        Ctrl.focus();
                        flag = false;
                    }
                }
            }
            else if (month > 12) {
                alert('Invalid Date');
                Ctrl.focus();
                flag = false;
            }
            // otherwise return true
            return flag;
        }



        function printPartOfPage() {
            var printDiv = document.getElementById("divPrint").innerHTML;
            var windowUrl = 'about:blank';
            var uniqueName = new Date();
            var windowName = 'Print' + uniqueName.getTime();
            var printWindow = window.open(windowUrl, windowName, 'left=5000,top=5000,width=0,height=0');
            printWindow.document.write(printDiv);
            printWindow.document.close();
            printWindow.focus();
            printWindow.print();
            printWindow.close();
            return false;
        }
    </script>

</head>
<body style="font-family:Verdana; font-size:11px;">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:HiddenField ID="hidFinyear" runat="server" />
    <div style="width: 90%; margin-left: 5%; margin-right: 5%;">
        <asp:Label ID="lblMsg" runat="server"></asp:Label>
        <asp:HyperLink ID="hyperChangeDate" runat="server" NavigateUrl="#" Text="Change Date"></asp:HyperLink>&nbsp;&nbsp;
        <asp:HyperLink ID="hyperPrint" runat="server" NavigateUrl="#" onclick="return printPartOfPage();"
            Text="Print"></asp:HyperLink>
    </div>
    <div id="divPrint" style="width: 90%; margin-left: 5%; margin-right: 5%;">
        <table width="100%">
            <tr>
                <td align="center" style="margin-bottom: 8px">
                    <asp:Label ID="lblCompanyName" runat="server" Font-Size="14px" Font-Bold="true"></asp:Label>
                </td>
            </tr>
            <tr>
                <td align="center" style="padding: 5px 0px 3px 0px;">
                    <asp:Label ID="lblHeading" runat="server" Font-Size="12px"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="width: 100%;">
                    <asp:GridView ID="grdBalanceSheet" Width="100%" ShowFooter="True" AutoGenerateColumns="false"
                        runat="server" OnRowDataBound="grdBalanceSheet_RowDataBound" BackColor="White"
                        BorderColor="#d6d3ce" BorderStyle="Solid" Font-Size="12px" BorderWidth="1px" CellPadding="4" ForeColor="Black"
                        GridLines="Horizontal">
                        <Columns>
                            <asp:BoundField HeaderText="Exp" DataField="LiabilityGroup" ItemStyle-Width="25%" ItemStyle-VerticalAlign="Top" ItemStyle-CssClass="LeftAlign">
                                <ItemStyle CssClass="LeftAlign" ></ItemStyle>
                            </asp:BoundField>
                            <asp:BoundField HeaderText="Total" DataField="LiabilityTotal" ItemStyle-Width="25%" ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Right"
                                ItemStyle-CssClass="RightAlign">
                                <ItemStyle HorizontalAlign="Right" CssClass="RightAlign"></ItemStyle>
                            </asp:BoundField>
                            <asp:BoundField HeaderText="Income" DataField="AssetsGroup" ItemStyle-VerticalAlign="Top" ItemStyle-Width="25%" ItemStyle-CssClass="LeftAlign">
                                <ItemStyle CssClass="LeftAlign" ></ItemStyle>
                            </asp:BoundField>
                            <asp:BoundField HeaderText="Total" DataField="AssetsTotal" ItemStyle-Width="25%" ItemStyle-HorizontalAlign="Right"
                                ItemStyle-CssClass="RightAlign" ItemStyle-VerticalAlign="Top">
                                <ItemStyle HorizontalAlign="Right" CssClass="RightAlign"></ItemStyle>
                            </asp:BoundField>
                        </Columns>
                        <FooterStyle BackColor="#e3eee3" ForeColor="Black" />
                        <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
                        <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#e3eee3" Font-Bold="True" ForeColor="Black" />
                    </asp:GridView>
                </td>
            </tr>
        </table>
    </div>
    <asp:Panel ID="PanelChangeDate" runat="server" Width="350px" Height="160px" Style="display: none"
        CssClass="modalPopup">
        <div style="width: 80%; margin: 20px 10% 10px 10%;">
            <table>
                <tr>
                    <td>
                        From date
                    </td>
                    <td style="padding-left: 10px">
                        <asp:TextBox ID="txtFromDate" runat="server" CssClass="input" ToolTip="DD/MM/YYYY"
                            Width="100px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        To Date
                    </td>
                    <td style="padding-left: 10px">
                        <asp:TextBox ID="txtToDate" runat="server" CssClass="input" ToolTip="DD/MM/YYYY"
                            Width="100px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <asp:Button ID="btnCangeDate" runat="server" OnClientClick="return Validation();"
                            CssClass="button" Text="Ok" ValidationGroup="V" OnClick="btnCangeDate_Click" />&nbsp;
                        <asp:Button ID="btnCancel" runat="server" CssClass="button" Text="Cancel" />
                    </td>
                </tr>
            </table>
        </div>
    </asp:Panel>
    <ajaxToolkit:ModalPopupExtender ID="modalDate" runat="server" CancelControlID="btnCancel"
        TargetControlID="hyperChangeDate" PopupControlID="PanelChangeDate" BackgroundCssClass="modalBackground">
    </ajaxToolkit:ModalPopupExtender>
    </form>
    
</body>
</html>